<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>购买记录</title>
</head>
<body>
	<jsp:include page="/WEB-INF/page/common/_header.jsp" />
	<jsp:include page="/WEB-INF/page/common/head.jsp" />
	<div class="pic-list">
		<ul class="clearfix">
			<c:if test="${orderList == null || orderList.isEmpty() }">
    			<p style="padding: 10px 10px;">暂无购买记录</p>
    		</c:if>
			<c:forEach var="itm" items="${orderList }">
				<li class="clearfix">
						<a href="<%=basePath %>/course/detail/${itm.courseId}">
							<div class="pic-list-l">
								<img src="${config.imgUrl }${itm.courseImg }" alt="" />
							</div>
						</a>
						<div class="pic-list-r">
							<p class="pic-list-title">
								${itm.courseName }
							</p>
							<p class="pic-list-priceWrap clearfix">
								<c:choose>
		    						<c:when test="${itm.orderStatus == '000' }"><span class="pic-list-stateTip">已支付</span></c:when>
		    						<c:when test="${itm.orderStatus == '001' }"><span class="pic-list-stateTip1" onclick="pay(${itm.orderNo})">未支付</span></c:when>
		    						<c:when test="${itm.orderStatus == '004' }"><span class="pic-list-stateTip" style="color: gray;">失效</span></c:when>
		    						<c:when test="${itm.orderStatus == '005' }"><span class="pic-list-stateTip">退款中</span></c:when>
		    						<c:when test="${itm.orderStatus == '006' }"><span class="pic-list-stateTip">已退款</span></c:when>
		    					</c:choose>
								<span class="pic-list-price">￥<span>${itm.payAmount }</span></span>
							</p>
						</div>
					</li>
			</c:forEach>
		</ul>
	</div>
	<jsp:include page="/WEB-INF/page/common/_footer.jsp" />
	<script type="text/javascript">
		function pay(orderNo){
			$.ajax({
		 		url : "<%=basePath%>/pay/agin",
		 		type : "post",
		 		data : {
		 			orderNo: orderNo
		 		},
		 		dataType : "json",
		 		async : false,
		 		success : function(data) {
		 			if(data.code == '000') {
		 				window.location.href = basePath + "/pay/detail?" + data.data;
		 			}else {
		 				alert(data.msg);
		 			}
		 		}, error:function(){
		 			alert("系统异常，请联系管理员");
        		}
		 	});
		}
	</script>
  </body>
</html>